﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataTightenXmlData" @search="getTableDataTightenXmlData">
      <el-row>
        
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="TID_FormItem" prop="TID" label="TID">
            <el-input-number v-model="searchDataTightenXmlData.TID" clearable></el-input-number>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="toolSerialNum_FormItem" prop="toolSerialNum" label="toolSerialNum">
            <el-input v-model="searchDataTightenXmlData.toolSerialNum" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="tighteningID_FormItem" prop="tighteningID" label="tighteningID">
            <el-input-number v-model="searchDataTightenXmlData.tighteningID" clearable></el-input-number>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="tool_id_FormItem" prop="tool_id" label="tool_id">
            <el-input-number v-model="searchDataTightenXmlData.tool_id" clearable></el-input-number>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="sn_FormItem" prop="sn" label="sn">
            <el-input v-model="searchDataTightenXmlData.sn" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="project_name_FormItem" prop="project_name" label="project_name">
            <el-input v-model="searchDataTightenXmlData.project_name" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="torque_FormItem" prop="torque" label="torque">
            <el-input v-model="searchDataTightenXmlData.torque" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="angle_FormItem" prop="angle" label="angle">
            <el-input v-model="searchDataTightenXmlData.angle" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="tightening_status_FormItem" prop="tightening_status" label="tightening_status">
            <el-input v-model="searchDataTightenXmlData.tightening_status" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="rawdata_time_FormItem" prop="rawdata_time" label="rawdata_time">
            <el-input v-model="searchDataTightenXmlData.rawdata_time" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="screw_id_FormItem" prop="screw_id" label="screw_id">
            <el-input-number v-model="searchDataTightenXmlData.screw_id" clearable></el-input-number>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="PointNum_FormItem" prop="PointNum" label="PointNum">
            <el-input-number v-model="searchDataTightenXmlData.PointNum" clearable></el-input-number>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="angle_offset_FormItem" prop="angle_offset" label="angle_offset">
            <el-input-number v-model="searchDataTightenXmlData.angle_offset" clearable></el-input-number>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="ArrTorque_FormItem" prop="ArrTorque" label="ArrTorque">
            <el-input v-model="searchDataTightenXmlData.ArrTorque" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="upload_status_FormItem" prop="upload_status" label="upload_status">
            <el-input v-model="searchDataTightenXmlData.upload_status" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="upload_time_FormItem" prop="upload_time" label="upload_time">
            <el-input v-model="searchDataTightenXmlData.upload_time" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="filed1_FormItem" prop="filed1" label="filed1">
            <el-input v-model="searchDataTightenXmlData.filed1" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="filed2_FormItem" prop="filed2" label="filed2">
            <el-input v-model="searchDataTightenXmlData.filed2" clearable></el-input>
        </el-form-item>
    </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/TightenXmlData/Add'" icon='fa fa-plus' type='primary' :button-text="$t('message._system.common.vm.add')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/TightenXmlData/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message._system.common.vm.batchdelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/TightenXmlData/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message._system.common.vm.import')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/TightenXmlData/TightenXmlDataExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message._system.common.vm.export')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefTightenXmlData" v-bind="tableDataTightenXmlData">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
          <el-button text type="primary" @click="OnEditrowClick(scope.row)" v-auth="'/api/TightenXmlData/Edit'">{{ $t('message._system.common.vm.edit') }}</el-button>
					<el-button text type="primary" @click="OnDetailsrowClick(scope.row)" v-auth="'/api/TightenXmlData/{id}'">{{ $t('message._system.common.vm.detail') }}</el-button>
					<el-popconfirm :title="$t('message._system.common.vm.deletetip')"  @confirm="onDelete(scope.row)">
						<template #reference>
							<el-button text type="danger" v-auth="'/api/TightenXmlData/BatchDelete'">{{ $t('message._system.common.vm.delete') }}</el-button>
						</template>
					</el-popconfirm>
        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="备份拧紧数据;true;TyMES.Controllers;TightenXmlData">
import {  ElMessageBox, ElMessage } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { TightenXmlDataApi } from '/@/api/record/TightenXmlData';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateTightenXmlData = reactive({
    
});

const searchDataTightenXmlData = ref({
    			TID: null,
			toolSerialNum: null,
			tighteningID: null,
			tool_id: null,
			sn: null,
			project_name: null,
			torque: null,
			angle: null,
			tightening_status: null,
			rawdata_time: null,
			screw_id: null,
			PointNum: null,
			angle_offset: null,
			ArrTorque: null,
			upload_status: null,
			upload_time: null,
			filed1: null,
			filed2: null,

});

// 定义变量内容
const tableRefTightenXmlData = ref();
const tableDataTightenXmlData = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
  
        {title:'TID',key: 'TID',type: 'text',isCheck: true},
        {title:'toolSerialNum',key: 'toolSerialNum',type: 'text',isCheck: true},
        {title:'tighteningID',key: 'tighteningID',type: 'text',isCheck: true},
        {title:'tool_id',key: 'tool_id',type: 'text',isCheck: true},
        {title:'sn',key: 'sn',type: 'text',isCheck: true},
        {title:'project_name',key: 'project_name',type: 'text',isCheck: true},
        {title:'torque',key: 'torque',type: 'text',isCheck: true},
        {title:'angle',key: 'angle',type: 'text',isCheck: true},
        {title:'tightening_status',key: 'tightening_status',type: 'text',isCheck: true},
        {title:'rawdata_time',key: 'rawdata_time',type: 'text',isCheck: true},
        {title:'screw_id',key: 'screw_id',type: 'text',isCheck: true},
        {title:'PointNum',key: 'PointNum',type: 'text',isCheck: true},
        {title:'angle_offset',key: 'angle_offset',type: 'text',isCheck: true},
        {title:'ArrTorque',key: 'ArrTorque',type: 'text',isCheck: true},
        {title:'upload_status',key: 'upload_status',type: 'text',isCheck: true},
        {title:'upload_time',key: 'upload_time',type: 'text',isCheck: true},
        {title:'filed1',key: 'filed1',type: 'text',isCheck: true},
        {title:'filed2',key: 'filed2',type: 'text',isCheck: true},
	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataTightenXmlData = () => {
    tableRefTightenXmlData.value.doSearch(TightenXmlDataApi().search, searchDataTightenXmlData.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.add'), CreateDialog, null, getTableDataTightenXmlData)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.edit'), EditDialog, row, getTableDataTightenXmlData)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.detail'), DetailsDialog, row, getTableDataTightenXmlData)
};

// 删除
const onDelete = (row: any) => {
    TightenXmlDataApi().delete([row.ID]).then(() => { getTableDataTightenXmlData()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefTightenXmlData.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      TightenXmlDataApi().delete(selectedids).then(() => { getTableDataTightenXmlData()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.import'), ImportDialog, null, getTableDataTightenXmlData)
};

const onExport = () => {
	const selected = tableRefTightenXmlData.value.getSelectedRows();
	if (selected.length > 0) {
		TightenXmlDataApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		TightenXmlDataApi().export({});
	}
};

// 页面加载时
onMounted(() => {
     
        getTableDataTightenXmlData();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

